::---------------------------------
:: ArchiveBytes v1.0 Windows.Script v1.0
:: Copyright 2008 Mark T. Ward
::
:: Licensed under the Apache License, Version 2.0 (the "License");
:: you may not use this file except in compliance with the License.
:: You may obtain a copy of the License at
::
::     http://www.apache.org/licenses/LICENSE-2.0
::
:: Unless required by applicable law or agreed to in writing, software
:: distributed under the License is distributed on an "AS IS" BASIS,
:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
:: See the License for the specific language governing permissions and
:: limitations under the License.
::---------------------------------
::@echo off

::------------------------------
:: [optiona] Mount network drives
::------------------------------
::[example] net use b: \\ComputerName\ShareName /user:UserName Password


::------------------------------
:: Create repository level lock for each archive repository in the archive repository folder
::------------------------------
:: [example] echo Lock > d:\ArchiveRepositoryPath\Archive\ComputerName.lock

::------------------------------
:: Remove the oldest archive entry in the respoistory. 
::------------------------------
:: [example] rmdir /s /q "d:\ArchiveRepositoryPath\Archive\01-Archive"

::------------------------------
:: Shuffle archive repository entries.  Age them +1
::------------------------------
:: [example] move /y "d:\ArchiveRepositoryPath\Archive\00-Archive" "d:\ArchiveRepositoryPath\Archive\01-Archive"

::------------------------------
:: Create repository 00 entry
::------------------------------
:: [example] mkdir "d:\ArchiveRepositoryPath\Archive\00-Archive\Data" 

::------------------------------
:: Create repository entry level lock.
::------------------------------
:: [example] echo Lock > d:\ArchiveRepositoryPath\Archive\00-Archive\ComputerName.lock


::------------------------------
:: Copy data for archiving into the temporary or local archive store
::------------------------------
:: [example] 7za a "d:\ArchiveRepositoryPath\Archive\00-Archive\Data\MyDocuments-Archive.zip" -y -v20m -r "c:\MyDocumentsPath\*" > "d:\ArchiveRepositoryPath\Archive\00-Archive\Data\MyDocuments-Archive.ZIP.log.txt"
:: [example verification] 7za t "d:\ArchiveRepositoryPath\Archive\00-Archive\Data\MyDocuments-Archive.zip.001" > "d:\ArchiveRepositoryPath\Archive\00-Archive\Data\MyDocuments-Archive.Test.log.txt"

::------------------------------
:: Repository verification hash calculation on local or temporary archive repository.
:: The hash will be used to verify respositories after they are copied.
::------------------------------
:: [example] fciv.exe d:\ArchiveRepositoryPath\Archive\00-Archive\Data\ -sha1 -wp -xml d:\ArchiveRepositoryPath\Archive\00-Archive\ComputerName.checksum.xml

::------------------------------
:: Copy the local or temporary repository entry to the other repositories
:: Note: the lock from the original repository will be copied.  Make sure that it is removed at the end.
::------------------------------
:: [example] xcopy /E /Y "d:\ArchiveRepositoryPath\Archive\00-Archive\*.*" "q:\ADifferentArchiveRepositoryPath\Archive\00-Archive"

::------------------------------
:: Verify repository copies
::------------------------------
:: [example] fciv.exe -v -bp d:\ArchiveRepositoryPath\Archive\00-Archive\Data\ -sha1 -wp -xml d:\ArchiveRepositoryPath\Archive\00-Archive\ComputerName.checksum.xml > "d:\ArchiveRepositoryPath\Archive\00-Archive\ComputerName.verify.txt"


::------------------------------
:: Remove locks
::------------------------------
:: [example] del d:\ArchiveRepositoryPath\Archive\00-Archive\ComputerName.lock
:: [example] del d:\ArchiveRepositoryPath\Archive\ComputerName.lock


::------------------------------
:: [optiona] Unmount network drives
::------------------------------
::net use /delete b:
